package com.lsl.test1;

/**
 * @author lishuailong
 * @create 2020-06-15 15:47
 */
public class TestA {
    public static void main(String[] args) throws InterruptedException {
        MyThread myThread = new MyThread();

        MyThread myThread1= new MyThread();

        MyThread myThread2= new MyThread();

        myThread.setName("子线程1");
        myThread1.setName("子线程2");
        myThread2.setName("子线程3");

        myThread.start();
        myThread1.start();
        myThread2.start();

        System.out.println(" myThread.join();");
        myThread.join();
        System.out.println(" myThread1.join();");
        myThread1.join();
        System.out.println(" myThread2.join();");
        myThread2.join();

        System.out.println("所有线程都执行完毕！");

    }
}

class MyThread extends Thread{
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            try {
                sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(currentThread().getName()+":"+i);
        }
    }
}

